﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GoodsReportManage.ItemClass;
using GoodsReportManage.Goods;

namespace GoodsReportManage.Stock
{
    public partial class    StockIn : Form
    {
        public StockIn()
        {
            InitializeComponent();
        }
        SqlBaseClass G_SqlClass = new SqlBaseClass();
        WinOperationClass G_WinFormClass = new WinOperationClass();
        int G_Int_status;  //保存工具栏按钮操作状态
        
        private void BindData()
        {
            //绑定数据显示控件
            string P_Str_cmdtxt1 = "SELECT StockTempID,UserID,GoodsID as 商品ID,GoodsName as 商品名称";
            P_Str_cmdtxt1 += ",FDepotName 调出仓库,LDepotName as 调入仓库,CGoodsTime as 调动时间";
            P_Str_cmdtxt1 += ",StockNum as 库存数量,CGoodsNum as 调出数量 FROM tb_StockTemp";
            this.dgvStockIn.DataSource = G_SqlClass.GetDs(P_Str_cmdtxt1).Tables[0];
        }

        /// <summary>
        /// 控制控件状态
        /// </summary>
        private void ControlStatus()
        {
            this.toolSave.Enabled = !this.toolSave.Enabled;
            this.toolAdd.Enabled = !this.toolAdd.Enabled;
            this.toolCancel.Enabled = !this.toolCancel.Enabled;
            groupBox1.Enabled = !this.groupBox1.Enabled;

        }

        /// <summary>
        /// 将控件恢复到原始状态
        /// </summary>
        private void ClearControls()
        {
            
        }

        private void toolAdd_Click(object sender, EventArgs e)
        {

            ControlStatus();
            ClearControls();
        }

        private void toolCancel_Click(object sender, EventArgs e)
        {
            ControlStatus();
            ClearControls();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PurchaseOrderFind wndPOfind = new PurchaseOrderFind();
            wndPOfind.FindPOEvent += new EventHandler(FindPO);
            wndPOfind.StartPosition = FormStartPosition.CenterParent;
            wndPOfind.ShowDialog();
        }

        private void FindPO(object sender, EventArgs e)
        {
            POEventArgs args = e as POEventArgs;
            this.labComanyName.Text = args.POID.ToString();
            this.txtPOID.Text = args.POID;
            this.labComanyName.Text = args.CompanyName.ToString();
        }
    }


}
